package com.community.owner.controller;


import com.community.common.core.domain.AjaxResult;
import com.community.common.entity.ParkingSpace;
import com.community.owner.service.impl.OwnerParkingSpaceServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/parkingSpace")
public class OwnerParkingSpaceController {

    @Autowired
    private OwnerParkingSpaceServiceImpl parkingSpaceService;

    @GetMapping("/getParkingSpaceByOwnerId/{ownerId}")
    public AjaxResult getParkingSpaceByOwnerId(@PathVariable Long ownerId) {
        try {
            List<ParkingSpace> parking= parkingSpaceService.getParkingSpaceByOwnerId(ownerId);
            return AjaxResult.success(parking);
        } catch (Exception e) {
            return AjaxResult.error("获取车位信息失败: " + e.getMessage());
        }
    }
}
